<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : cm_100_01.jsp
    Description : 커뮤니티 관리자 목록
    author EUNGA
    since 2012. 7. 25.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 7. 25.     EUNGA     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/mn/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/co/mn/include/session.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/co/mn/include/header.jspf" %>
<script type="text/javaScript" language="javascript">
$(document).ready(function() {
    /* form validation check */
    onloadCharCheck();
    $("#srchButn").bind("click", moveSearch);    // 검색
    $("#rgstButn").bind("click", moveRgstPage);    // 등록
    $("#delButn").bind("click", delSubmit);    // 삭제
    
    $("#srchTxt").bind("keydown", eventEnter);    // 엔터키 제어
});

/*  
 * 페이징
 */
function movePage(num) {
    $("#currentPageNo").val(num);
    $("#mainForm").attr('action','/cm_100_01.do').submit();
}

/*
 * 검색
 */
function moveSearch() {
    if (!isSchrChk($("#srchTxt").val())) {
        alert("검색어에는 특수문자를 입력할 수 없습니다.");
        $("#srchTxt").focus();
        return false;
    }
    
    if (getTxtBkmgRmov($("#srchTxt").val())=="") {
        alert("검색어를 입력해주세요.");
        $("#srchTxt").focus();
        return false;
    }
    $("#currentPageNo").val("1");
    $("#mainForm").attr('action','/cm_100_01.do').submit();
}

/*
 * 검색 Text EnterKey 처리
 */
function eventEnter() {
    if (event.key == 13) {
        moveSearch();
    }
}

/*
 * 상세페이지 이동
 */
function moveDtlPage(idx) {
    $("#blbIdx").val(idx);
    $("#mainForm").attr('action','/cm_100_02.do').submit();
}

/*
 * 등록페이지 이동
 */
function moveRgstPage() {
    $("#mainForm").attr('action','/cm_100_04.do').submit();
}

/*
 * 삭제처리
 */
 function delSubmit() {
     if ($("input[name='arrIdx']").length < 1) return;
     
     var delIdx = "";
     
     for (var i = 0; i < $("input[name='arrIdx']").length; i++){
         if ($("input[name='arrIdx']").eq(i).is(":checked") == true ){
             delIdx = delIdx + $("input[name='arrIdx']").eq(i).val() + ","; 
         } 
     }
     
     if (delIdx == "") {
         alert("삭제할 게시물을 선택해 주세요.");
         return;
     }
     
     delIdx = delIdx.substring(0, delIdx.length-1);

     $("#delIdx").val(delIdx);
     $("#currentPageNo").val("1");
     
     if (confirm("삭제하시겠습니까?")) {
         $("#mainForm").attr('target','comIframe');
         $("#mainForm").attr('action','/cm_100_06.do').submit();   
     } else {
         return false;
     }
 }
</script>
</head>
<body>
<div id="wrap">
    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/top.jsp" %>
    <!-- top -->
 
    <!-- container -->
    <div id="container">
        <!-- LNB -->
        <%@ include file="/WEB-INF/jsp/co/mn/include/left.jsp" %>
        <!-- LNB -->
        <div id="contents">
            <!-- location -->
            <%@ include file="/WEB-INF/jsp/co/mn/include/location.jsp" %>
            <!-- location -->
            <form id="mainForm" name="mainForm" method="post">
            <div class="searchWrap">
                <p class="pageResult flow">총&nbsp;<span>${paginationInfo.totalRecordCount}</span>건, 현재페이지 ${paginationInfo.currentPageNo}/${paginationInfo.totalPageCount} </p>
                <div class="search reverse">
                    <input type="hidden" id="currentPageNo" name="currentPageNo" value="${paginationInfo.currentPageNo}" />
                    <input type="hidden" id="blbIdx" name="blbIdx" value="" />
                    <input type="hidden" id="delIdx" name="delIdx" value="" />
                    <fieldset>
                        <legend class="invisible">Search</legend>
                        <select id="srchScn" name="srchScn">
                            <option value="" <c:if test="${rqInfo.srchScn == '' }"><c:out value="selected" /></c:if>>전체</option>
                            <option value="titl" <c:if test="${rqInfo.srchScn == 'titl' }"><c:out value="selected" /></c:if>>제목</option>
                            <option value="sbc" <c:if test="${rqInfo.srchScn == 'sbc' }"><c:out value="selected" /></c:if>>내용</option>
                        </select><input type="text" class="formSearch" id="srchTxt" name="srchTxt" title="검색어입력" value="${rqInfo.srchTxt }" maxlength="10" /><input type="image" class="btnSearch" id="srchButn" name="srchButn" src="/img/mng/btn/btn_search.gif" alt="검색" title="검색" />
                    </fieldset>
                </div>
            </div>
            <table border="1" class="resultTable" summary="커뮤니티 관리 표">
                <colgroup>
                    <col width="4%" />
                    <col width="6%" />
                    <col width="8%" />
                    <col width="15%" />
                    <col width="32%" />
                    <col width="8%" />
                    <col width="8%" />
                    <col width="10%" />
                    <col width="8%" />
                </colgroup>
                <thead>
                    <tr>
                        <th><input type="checkbox" id="fCk" name="fCk" value="all" onclick="setAllChk(this, document.mainForm.arrIdx)" /></th>
                        <th>번호</th>
                        <th>이름</th>
                        <th>기관명</th>
                        <th>제목</th>
                        <th>첨부파일</th>
                        <th>정렬순서</th>
                        <th>등록일</th>
                        <th>조회수</th>
                    </tr>
                </thead>
                <tbody>
                 <c:choose>
                    <c:when test="${resultList != null && !empty resultList }">
                        <c:forEach var="result" items="${resultList }" varStatus="status">
                    <tr>
                        <td><input type="checkbox" id="arrIdx" name="arrIdx" value="${result.blbIdx }" /></td>
                        <td>${result.blcNo }</td>
                        <td>${result.pprrNm }</td>
                        <td class="dirLeft">${result.instNm }</td>
                        <td class="dirLeft"><a href="#" onclick="moveDtlPage('${result.blbIdx}');return false;">${result.titl }</a></td>
                        <td>
                            <c:if test="${result.filNm != null }">
                            <a href="#" onclick="getUpFileDownload('0050','${result.blbIdx}');return false;"><img src="/img/mng/ico/ico_att.gif" alt="첨부파일" /></a>
                            </c:if>
                        </td>
                        <td>
                        	<c:if test="${result.sortNum < 1 }">우선노출</c:if>
                        	<c:if test="${result.sortNum ==1 }">일반노출</c:if>
                        </td>
                        <td>${result.rgstDt }</td>
                        <td>${result.iqNo }</td>
                    </tr>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                    <tr>
                        <td colspan="9">등록된 내용이 없습니다.</td>
                    </tr>
                    </c:otherwise>
                </c:choose>
                    
                </tbody>
            </table>
            </form>
            <div class="btnBoard">
                <span class="flow"><input type="submit" id="delButn" value="삭제" /></span>
                <span class="reverse"><a href="#" id="rgstButn" name="rgstButn" title="등록"  >등록</a></span>
            </div>
            <div class="pageNate">
                <able:pagination paginationInfo="${paginationInfo }" type="image" jsFunction="movePage" />
            </div>
        </div>
    </div>
    <!-- /container -->
 
    <!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/bottom.jsp" %>
    <!-- /footer -->
</div>
</body>
</html>